package com.lzm.service;

import com.lzm.mapper.DepartmentsMapper;
import com.lzm.mapper.DoctorMapper;
import com.lzm.pojo.Departments;
import com.lzm.pojo.DepartmentsExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@Service
public class departmentsService {
    @Resource
    private DepartmentsMapper departmentsMapper;
    @Resource
    private DoctorMapper doctorMapper;

    public List<Departments> getList(){
        DepartmentsExample example = new DepartmentsExample();
        DepartmentsExample.Criteria criteria = example.createCriteria();
        List<Departments> departments = departmentsMapper.selectByExample(example);
        List<Departments> departments2 = new ArrayList<>();
        for (Departments department : departments) {
            Departments departments1 = departmentsMapper.queryById(department.getD_id());
            departments2.add(departments1);
        }
        System.out.println(departments2);
        return departments2;
    }

    public Departments getSecondList(int d_id){
        Departments departments1 = departmentsMapper.queryById(d_id);
        return departments1;
    }
}
